package com.tian.mybatis.config;

import javax.sql.DataSource;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author tianwc  公众号：java后端技术全栈、面试专栏
 * @version 1.0.0
 * @date 2023年09月21日 11:11
 * 在线刷题 1200+题和1000+篇干货文章：<a href="https://woaijava.cc/">博客地址</a>
 * <p>
 *
 * mybatis 配置类 核心类
 *
 * <configuration>
 *     <dataSource>
 *         <property name="driver" value="com.mysql.cj.jdbc.Driver"/>
 *         <property name="url"
 *                   value="jdbc:mysql://localhost:3306/charge-station?characterEncoding=utf8&amp;useSSL=false&amp;serverTimezone=GMT%2B8&amp;allowPublicKeyRetrieval=true"/>
 *         <property name="username" value="root"/>
 *         <property name="password" value="123456"/>
 *     </dataSource>
 *     <mappers>
 *         <mapper resource="mapper/UserMapper.xml"/>
 *         //可以配置多个
 *     </mappers>
 * </configuration>
 */
public class Configuration {
    private DataSource dataSource;
    /**
     * key=namespace +"."+ id
     * 比如：
     * com.tian.test.UserMapper.selectById
     * com.tian.test.UserMapper.insert
     *
     * <mapper namespace="com.tian.test.UserMapper">
     *
     *     <select id="selectById" resultType="com.tian.test.User" parameterType="java.lang.Integer">
     *         select * from user where id = #{id}
     *     </select>
     *
     *     <insert id="insert" resultType="java.lang.Integer" parameterType="com.tian.test.User">
     *         insert into user values (null,#{userName})
     *     </insert>
     * </mapper>
     *
     *
     */
    private Map<String ,MapperStatement> mapperStatementMap=new ConcurrentHashMap<>();

    public DataSource getDataSource() {
        return dataSource;
    }

    public void setDataSource(DataSource dataSource) {
        this.dataSource = dataSource;
    }

    public Map<String, MapperStatement> getMapperStatementMap() {
        return mapperStatementMap;
    }

    public void setMapperStatementMap(Map<String, MapperStatement> mapperStatementMap) {
        this.mapperStatementMap = mapperStatementMap;
    }

    @Override
    public String toString() {
        return "Configuration{" +
                "dataSource=" + dataSource +
                ", mapperStatementMap=" + mapperStatementMap +
                '}';
    }
}
